/*
** Copyright (c) 2010  Kimmo 'Rainy' Pekkola
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program.  If not, see http://www.gnu.org/licenses.
*/

#ifndef THEMEMANAGER_H
#define THEMEMANAGER_H

#ifndef WITH_PRECOMPILED
#include "precompiled.h"
#endif

#include <QObject>
#include <QStringList>

enum THEME_IMAGES
{
    IMAGE_BACKGROUND = 1,
    IMAGE_NUMBERS,
    IMAGE_PAUSE,
    IMAGE_RESET,
    IMAGE_START,
    IMAGE_RIGHT_BUTTON,
    IMAGE_LEFT_BUTTON
};

enum THEME_COLORS
{
    COLOR_BACKGROUND,
    COLOR_HELP
};

enum THEME_OFFSETS
{
    OFFSET_LEFT_BUTTON,
    OFFSET_RIGHT_BUTTON
};

#define SOUND_DOWN   0x0100000
#define SOUND_UP     0x0200000
#define SOUND_TIME   0x0400000
#define SOUND_REPEAT 0x8000000
#define SOUND_TICK_MASK 0x00FFFFF

class CThemeManager : public QObject
{
    Q_OBJECT

public:
    static CThemeManager& instance();

    void resetTheme();
    QStringList getThemes();
    void chooseTheme(const QString& strTheme);

    bool hasBackground() { return m_bHasBackground; }
    bool hasReflection() { return m_bHasRefrection; }

    QImage getImage(THEME_IMAGES image);
    QColor getColor(THEME_COLORS color);
    QPoint getOffset(THEME_OFFSETS offset);
    QObject* playSound(int ticks);
    QSize getButtonSize() { return m_ButtonSize; }

private:
    CThemeManager();
    ~CThemeManager();

    QString m_CurrentTheme;                     ///<
    QMap<THEME_IMAGES, QString> m_MapImages;    ///<
    QMap<THEME_COLORS, QColor> m_MapColors;     ///<
    QMap<THEME_OFFSETS, QPoint> m_MapOffsets;   ///<
    QMap<int, QString> m_MapSounds;             ///<
#ifdef WITH_PHONON
    QMap<QString, Phonon::MediaObject*> m_AudioObjects;        ///<
#else
    QMap<QString, QSound*> m_AudioObjects;        ///<
#endif
    QSize m_ButtonSize;                         ///<
    bool m_bHasRefrection;                      ///<
    bool m_bHasBackground;                      ///<
};

#endif // THEMEMANAGER_H
